const markData = {
  state: {
    qaTaskId: '',
    qaResultId: '',
    mQaResultcurrentIndex: 0,
    paperToolPosition: [],
    markAnnotations: new Map(),
    remarkList: new Map(),
    playStatus: {
      pcd: true,
      pic: true,
    },
    queryTask: {},
  },

  mutations: {
    MQA_RESULT_CURRENT_INDEX_CACHED_VIEWS: (state, currentIndex) => {
      state.mQaResultcurrentIndex = currentIndex
    },
    PAPER_TOOL_POSITION_CACHED_VIEWS: (state, paperToolPosition) => {
      state.paperToolPosition = paperToolPosition
      console.log('1: ', paperToolPosition)
    },
    MARK_ANNOTATIONS_CACHED_VIEWS: (state, markAnnotations) => {
      state.markAnnotations.clear()
      markAnnotations.forEach((annotation) => {
        state.markAnnotations.set('MA:' + annotation.mQaResultId, annotation)
      })
    },
    REMARK_LIST_CACHED_VIEWS: (state, remarkList) => {
      state.remarkList.clear()
      remarkList.forEach((remark) => {
        const storeKey = 'TaskId:' + remark.taskId + ';mQaResultId:' + remark.mQaResultId
        let rows = state.remarkList.get(storeKey)
        if (!rows) {
          rows = new Array()
        }
        rows.push(remark)
        state.remarkList.set(storeKey, rows)
      })
    },
    QUERY_TASK_CACHED_VIEWS: (state, queryTask) => {
      let queryParams = {
        pageNum: queryTask.pageNum,
        pageSize: queryTask.pageSize,
        parentId: queryTask.parentId,
        deptId: queryTask.deptId,
        taskName: queryTask.taskName,
        orderNum: queryTask.orderNum,
        taskStatus: queryTask.taskStatus,
        markType: queryTask.markType,
      }
      state.queryTask[queryTask.parentId] = queryParams
    },
  },

  actions: {
    mqaResultCurrentIndexCached({ commit }, currentIndex) {
      commit('MQA_RESULT_CURRENT_INDEX_CACHED_VIEWS', currentIndex)
    },
    paperToolPositionCached({ commit }, paperToolPosition) {
      commit('PAPER_TOOL_POSITION_CACHED_VIEWS', paperToolPosition)
    },
    markAnnotationsCached({ commit }, markAnnotations) {
      commit('MARK_ANNOTATIONS_CACHED_VIEWS', markAnnotations)
    },
    remarkListCached({ commit }, remarkList) {
      commit('REMARK_LIST_CACHED_VIEWS', remarkList)
    },
    queryTaskCached({ commit }, queryTask) {
      commit('QUERY_TASK_CACHED_VIEWS', queryTask)
    },
  },
}

export default markData
